#include "Client.hpp"
#include "ClientCollection.hpp"

Client::Client(){
	active = false;
}

void Client::setup(std::string inName, const sf::IpAddress& inAddress, const unsigned short inPort){
	active = true;
    name = inName;
    saddress = inAddress.toString();
    
    address = sf::IpAddress(inAddress);
    port = inPort;
    lastMessage.restart();
    outQueue.clearQueue();
}

void Client::push(lua_State* luaState){
    luabind::object o = luabind::object(luaState, this);
    o.push(luaState);
}

void Client::bind(lua_State* luaState){
	entity.bind(luaState);
    luabind::module(luaState)[
        luabind::class_<Client>("Client")
            .def_readwrite("name", &Client::name)
			.def_readonly("entity", &Client::entity)
            .def_readonly("index", &Client::index)
            .def_readonly("address", &Client::saddress)
    ];
}

Client::~Client(){
}